---
title: Use PromptL with your Provider
description: Learn how to use PromptL with different LLM providers
---

## Overview

While most LLM providers follow a similar chat-like structure, there are subtle differences in how prompts are formatted and processed. PromptL addresses these differences by providing **Adapters** for each major provider, ensuring that your prompts are correctly formatted and seamlessly integrated.

Currently, PromptL supports:
- [OpenAI](/promptl/usage/adapters/openai)
- [Anthropic](/promptl/usage/adapters/anthropic)

More providers will be supported in the future, and you can even create your own custom adapters for unsupported platforms.

---

## Why Adapters?

Adapters handle provider-specific definition differences, such as:
- Message structure: OpenAI uses `role`-based messages, while Anthropic uses a `user/assistant` prefix.
- API integration: Adapters ensure compatibility with the provider’s API.

By using an adapter, you don’t need to worry about these differences—PromptL handles them for you.

---

## Getting Started with Adapters

Here’s how to use an adapter in your project. For this example, we’ll use OpenAI:

```javascript
import { render, Adapter } from 'promptl-ai';

const { messages, config } = await render({
  prompt,
  adapter: Adapters.openai, // Specify the adapter
});
```

---

## Supported Providers

### OpenAI (default)
The OpenAI Adapter, which is selected by default, formats prompts to match OpenAI’s chat-completion API, including support for models like `gpt-4` and `gpt-3.5`.

- [Learn more about the OpenAI Adapter](/promptl/usage/adapters/openai)

### Anthropic
The Anthropic Adapter ensures compatibility with Anthropic’s API.

- [Learn more about the Anthropic Adapter](/promptl/usage/adapters/anthropic)

<Note>
  Additional providers will be supported in the future. Check back for updates!
</Note>

---

## Extending Adapters

If you’re working with an unsupported provider, you can create your own adapter. Adapters are simple functions that transform PromptL’s `messages` and `config` into the format required by your provider.

An adapter is defined as an object with two functions: `{ fromPromptl, toPromptl }`.
Each function takes an object with `messages` and `config` properties and returns the same object with transformed data.

To see the structure of `messages` used in PromptL, check out the [GitHub PromptL Repository](https://github.com/latitude-dev/promptl/blob/main/src/types/message.ts)

### Example: Custom Adapter
```javascript
const CustomAdapter = {
  fromPromptl: ({ messages, config }) => {
    // Transform PromptL messages to your provider's format
    const formattedMessages = messages.map((msg) => ({
      role: msg.type,
      content: msg.text,
    }));

    return { messages: formattedMessages, config };
  },

  toPromptl: ({ messages, config }) => {
    // Transform your provider's messages to PromptL format
    const formattedMessages = messages.map((msg) => ({
      type: msg.role,
      text: msg.content,
    }));

    return { messages: formattedMessages, config };
  },
};
```

Pass your custom adapter to the `render` function:

```javascript
const { messages, config } = await render({
  prompt,
  adapter: CustomAdapter,
});
```

---

## Contribute or Request Support

We’re constantly working to support more providers. If you’d like to request a specific provider or contribute an adapter, check out our [GitHub repository](https://github.com/latitude-dev/promptl).

---

## Summary

Adapters make it easy to use PromptL with different LLM providers by handling provider-specific formatting and configuration. Whether you’re using OpenAI, Anthropic, or another platform, PromptL ensures seamless integration. Get started with a supported adapter or build your own for maximum flexibility.
